package com.review.math;

public class GcdAndLcm {
    // 最大公约数
    public int gcd(int m, int n) {
        if (n > m) {
            return gcd(n, m);
        }
        int tmp;
        while (m % n != 0) {
            tmp = m % n;
            m = n;
            n = tmp;
        }
        return n;
    }

    // 最小公倍数
    public int lcm(int m, int n) {
        return m * n / gcd(m, n);
    }

    public static void main(String[] args) {
        GcdAndLcm gcdAndLcm = new GcdAndLcm();
        System.out.println(gcdAndLcm.gcd(5, 7));
        System.out.println(gcdAndLcm.lcm(5, 7));
    }
}
